package com.czy.service.impl;

import com.czy.common.Result;
import com.czy.dao.FriendDao;
import com.czy.model.Friend;
import com.czy.model.UserInfo;
import com.czy.service.AccountService;
import com.czy.service.FriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @Author: czy
 * @Date: 2019/11/12 10:23
 */
@Service
public class FriendServiceImpl implements FriendService{
    @Autowired
    private FriendDao friendDao;

    @Autowired
    private AccountService accountService;

    /**
     * 获取朋友列表
     * @return
     */
    @Override
    public Result getFriendList() {
        UserInfo currentUser = accountService.getCurrentUser();
        if (currentUser==null){
            return null;
        }
        Integer userId = currentUser.getUserId();
        List<Friend> friendList = friendDao.getFriendList(userId);
        return Result.success(friendList);
    }
}
